import sys
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtGui import QCloseEvent

from temp import *

class MyTab(QtWidgets.QWidget):
    def __init__(self, parent=None):
        super(MyTab, self).__init__()
        self.tableWidget = QtWidgets.QTableWidget(0, 1)
        self.tableWidget.setHorizontalHeaderLabels(
            ['Значение']
        )
        self.tableWidget.horizontalHeader().setDefaultSectionSize(200)  
        vbox = QtWidgets.QVBoxLayout(self)
        vbox.addWidget(self.tableWidget)
        
    def func_connect(self, data: list):
        self.tableWidget.setRowCount(len(data))
        for i in range(len(data)):
            self.tableWidget.setItem(i, 0, QtWidgets.QTableWidgetItem(str(data[i])))
        

class MyWindow(QtWidgets.QMainWindow):
    def __init__(self):
        super().__init__()
        self.centralwidget = QtWidgets.QWidget()
        self.setCentralWidget(self.centralwidget)

        self.tabWidget = QtWidgets.QTabWidget()
        self.layout = QtWidgets.QGridLayout(self.centralwidget)
        self.layout.addWidget(self.tabWidget)
    def new_tab(self, title: str, data: list):
        index = self.tabWidget.count() - 1
        tabPage = MyTab(self)
        tabPage.func_connect(data)
        self.tabWidget.insertTab(index, tabPage, title)
        self.tabWidget.setCurrentIndex(index)
    

class GraphicsData:
    def __init__(self, path):
        self.excel = ReadExcel(path)
    def one(self, win):
        win.new_tab('PIND', self.excel.getPIND())

    def second(self, win):
        win.new_tab('FX', self.excel.getFX())
        win.new_tab('FY', self.excel.getFY())
        win.new_tab('FSUM', self.excel.getFSUM())
        win.new_tab('BETA', self.excel.getBETA())
        win.new_tab('GAM', self.excel.getGAM())
        win.new_tab('PXZ', self.excel.getPXZ())
        win.new_tab('PYZ', self.excel.getPYZ())

    def third(self, win):
        win.new_tab('FX1', self.excel.getFX1())
        win.new_tab('FYK1', self.excel.getFYK1())
        win.new_tab('FSUM', self.excel.getFSUM1())
        win.new_tab('BETA1', self.excel.getBETA1())
        win.new_tab('GAM1', self.excel.getGAM1())
        win.new_tab('FXK2', self.excel.getFXK2())
        win.new_tab('FYK2', self.excel.getFYK2())
        win.new_tab('FSUM2', self.excel.getFSUM2())
        win.new_tab('BETA2', self.excel.getBETA2())
        win.new_tab('GAM2', self.excel.getGAM2())
        win.new_tab('FXK3', self.excel.getFXK3())
        win.new_tab('FYK3', self.excel.getFYK3())
        win.new_tab('BETA3', self.excel.getBETA3())
        win.new_tab('GAM3', self.excel.getGAM3())
        win.new_tab('FXK4', self.excel.getFXK4())
        win.new_tab('FYK4', self.excel.getFYK4())
        win.new_tab('FSUM4', self.excel.getFSUM4())
        win.new_tab('BETA4', self.excel.getBETA4())
        win.new_tab('GAM4', self.excel.getGAM4())

    def fourth(self, win):
        self.second(win)
        self.third(win)
        win.new_tab('FXK5', self.excel.getFXK4())
        win.new_tab('FYK5', self.excel.getFYK4())
        win.new_tab('FSUM5', self.excel.getFSUM4())
        win.new_tab('BETA5', self.excel.getBETA4())
        win.new_tab('GAM5', self.excel.getGAM4())
        win.new_tab('FXK6', self.excel.getFXK4())
        win.new_tab('FYK6', self.excel.getFYK4())
        win.new_tab('FSUM6', self.excel.getFSUM4())
        win.new_tab('BETA6', self.excel.getBETA4())
        win.new_tab('GAM6', self.excel.getGAM4())
        win.new_tab('FXK7', self.excel.getFXK4())
        win.new_tab('FYK7', self.excel.getFYK4())
        win.new_tab('FSUM7', self.excel.getFSUM4())
        win.new_tab('BETA7', self.excel.getBETA4())
        win.new_tab('GAM7', self.excel.getGAM4())

    def show(self, step: int, win):
        # app = QtWidgets.QApplication(sys.argv)
        # app.setFont(QtGui.QFont("Times", 10))
        match step:
            case 1: self.one(win)
            case 2: self.second(win)
            case 3: self.third(win)
            case 4: self.fourth(win)
        win.resize(1280, 720)
        win.show()